package cn.uexpo.lhz.biz.impl;

import java.util.List;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;



import cn.uexpo.lhz.biz.ExpoBiz;
import cn.uexpo.lhz.common.oldBase.BOException;
import cn.uexpo.lhz.common.oldUtils.PageRequest;
import cn.uexpo.lhz.common.oldUtils.PageResult;
import cn.uexpo.lhz.common.oldUtils.PageUtils;
import cn.uexpo.lhz.dao.ExpoMapper;
import cn.uexpo.lhz.domain.Expo;
import cn.uexpo.lhz.domain.ExpoExample;

@Transactional
@Service
public class ExpoBizImpl implements ExpoBiz {

	@Autowired
	private ExpoMapper expoMapper;
	@Override
	public int insert(Expo record) throws BOException {
		// TODO Auto-generated method stub
		return expoMapper.insert(record);
	}

	@Override
	public int insertSelective(Expo record) throws BOException {
		// TODO Auto-generated method stub
		return expoMapper.insertSelective(record);
	}

	@Override
	public int deleteByPrimaryKey(Integer id) throws BOException {
		// TODO Auto-generated method stub
		return expoMapper.deleteByPrimaryKey(id);
	}

	@Override
	public int deleteEntity(Expo record) throws BOException {
		// TODO Auto-generated method stub
		return expoMapper.deleteByPrimaryKey(record.getId());
	}

	@Override
	public int deleteByIds(List<Integer> ids) throws BOException {
		// TODO Auto-generated method stub
		for (Integer id : ids) {
			expoMapper.deleteByPrimaryKey(id);
		}
		return 1;
	}

	@Override
	public int delete(List<Expo> records) throws BOException {
		// TODO Auto-generated method stub
		for (Expo record : records) {
			expoMapper.deleteByPrimaryKey(record.getId());
		}
		return 1;
	}

	@Override
	public int deleteByExample(ExpoExample example) throws BOException {
		// TODO Auto-generated method stub
		return expoMapper.deleteByExample(example);
	}

	@Override
	public int updateByPrimaryKey(Expo record) throws BOException {
		// TODO Auto-generated method stub
		return expoMapper.updateByPrimaryKey(record);
	}

	@Override
	public int updateByPrimaryKeySelective(Expo record) throws BOException {
		// TODO Auto-generated method stub
		return expoMapper.updateByPrimaryKeySelective(record);
	}

	@Override
	public int updateByExampleSelective(Expo record, ExpoExample example) throws BOException {
		// TODO Auto-generated method stub
		return expoMapper.updateByExampleSelective(record,example);
	}

	@Override
	public int updateByExample(Expo record, ExpoExample example) throws BOException {
		// TODO Auto-generated method stub
		return expoMapper.updateByExample(record,example);
	}

	@Override
	public Expo selectByPrimaryKey(Integer id) throws BOException {
		// TODO Auto-generated method stub
		return expoMapper.selectByPrimaryKey(id);
	}

	@Override
	public Expo selectByUniqueCode(String uniqueCode) throws BOException {
		// TODO Auto-generated method stub
//		Expo item=null;
//		ExpoExample example=new ExpoExample();
//		ExpoExample.Criteria citeria=example.createCriteria();
//		 citeria.andExtstr3EqualTo(uniqueCode);
//		 List<Expo> items=expoMapper.selectByExample(example);
//		 if (items!=null&&items.size()>0) {
//			 item=items.get(0);
//		}
//		return item;
		return null;
	}

	@Override
	public List<Expo> selectByExample(ExpoExample example) throws BOException {
		// TODO Auto-generated method stub
		return expoMapper.selectByExample(example);
	}

	@Override
	public long countByExample(ExpoExample example) throws BOException {
		// TODO Auto-generated method stub
		return expoMapper.countByExample(example);
	}

	@Override
	public PageResult findPage(PageRequest pageRequest, ExpoExample example) throws BOException {
		int pageNum = pageRequest.getPage();
		int pageSize = pageRequest.getLimit();
	    PageHelper.startPage(pageNum, pageSize);
	    List<Expo> records = (List<Expo>) expoMapper.selectByExample(example);
	    return PageUtils.getPageResult(pageRequest, new PageInfo<Expo>(records));
	}

	//根据id 及时间查询对应展会
		@Override
		public Expo selectArea(Expo record) {
			// TODO Auto-generated method stub
			return expoMapper.selectArea(record);
		}



}
